<%--
    Document   : FormCreaDesiderio
    Created on : 20-apr-2010, 17.52.56
    Author     : Rachid Ouchary, Fabio Strocco, Max Passaghe, Marco Tansini.
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" import="servlet.ServletUtil"
        import="java.util.*"
        import="entity.*" %>
<%
            Collection<Category> categoryList = (Collection<Category>) request.getAttribute(ServletUtil.PARAM_CATEGORY_LIST);
%>
<script type="text/javascript" src="javascript/base.js"></script>
<script type="text/javascript" src="javascript/checks.js"></script>
<script type="text/javascript">
    function bindSubCategory(id) {
        clearOptionList();
        insertOption('-1', '---');
        <%for(Category category : categoryList) { %>
                if(id == '<%= category.getId()%>') {
                    <%
                    Collection<Category> subCategoryList = category.getSottoCategorie();
                    for(Category subCategory : subCategoryList) {
                    %>
                    insertOption("<%= subCategory.getId()%>", "<%= subCategory.getCatName()%>");
                    <%}%>
                }
        <%}%>
    }
</script>
<div id="main_content"> <img src="images/div_centrale_top.png" width="526" height="18" />
    <h1>Crea un desiderio</h1>
    <form action="MainDispatcher?operation=<%= ServletUtil.ACTION_CREA_DESIDERIO%>" onsubmit="return checkDesiderio()" method="post" target="_self">
        <table width="508" class="tableItemList" >
            <tr>
                <td width="36" rowspan="4" class="tdBull"><img src="images/bull.png" width="22" height="20" /></td>
                <td colspan="3"><table width="360" class="tabellaCategoria">
                        <tr>
                            <td width="32%"><p class="itemLabel">Scegli la categoria:</p></td>
                            <td width="68%">
                                <select id="mainCategory" name="<%= ServletUtil.PARAM_MAIN_CATEGORY%>" onclick="bindSubCategory(this.value)" class="selCategoria1">
                                    <option value="-1" selected="selected">Categoria</option>
                                    <% for (Category category : categoryList) {%>
                                    <option value="<%= category.getId()%>"><%= category.getCatName()%></option>
                                    <%}%>
                                </select>
                                <select id="subCategory" name="<%= ServletUtil.PARAM_SUB_CATEGORY%>" class="selCategoria1">
                                    <option value="-1" selected="selected">---</option>
                                </select>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="3"></td>
            </tr>
            <tr>
                <td colspan="3">        
                   <textarea id="descrizione" name="<%= ServletUtil.PARAM_DESCRIZIONE%>" rows="2" class="txDescrizione"
                                            onclick="textAreaLeaveMessage(this, 'Descrizione')" style="color: gray">Descrizione</textarea>
                      <p id="err_crea_desiderio" class="genericError" style="visibility: hidden">* inserisci una descrizione</p>
                </td>                          
                                          
            </tr>
            <tr>
                <td width="196" valign="top"><span class="itemLabel">Voto: <br />
                        <label>
                            <input type="radio" name="<%= ServletUtil.PARAM_VOTO%>" value="1" id="voto_1" />
                            1</label>
                        <label>
                            <input type="radio" name="<%= ServletUtil.PARAM_VOTO%>" value="2" id="voto_2" />
                            2</label>
                        <label>
                            <input type="radio" name="<%= ServletUtil.PARAM_VOTO%>" value="3" id="voto_3" Checked />
                            3</label>
                        <label>
                            <input type="radio" name="<%= ServletUtil.PARAM_VOTO%>" value="4" id="voto_4" />
                            4</label>
                        <label>
                            <input type="radio" name="<%= ServletUtil.PARAM_VOTO%>" value="5" id="voto_5" />
                            5</label>
                    </span></td>
                <td width="36" valign="top"></td>
                <td width="208" valign="top"><span class="itemLabel">Priorit&agrave: <br />
                    </span>
                    <select name="<%= ServletUtil.PARAM_PRIORITY%>" class="selPriorita">
                        <option value="5">5 - Bisogno primario</option>
                        <option value="4">4 - Lo voglio</option>
                        <option value="3" selected="selected">3 - Mi piace</option>
                        <option value="2">2 - E' uno sfizio</option>
                        <option value="1">1 - Mah...</option>
                    </select></td>
            </tr>
        </table><input name="crea" type="image" value="crea" style="margin:15px 0px 0px 350px;" src="images/btCrea.png" />
    </form>
    <img src="images/div_centrale_bottom.png" width="526" height="12" /> </div>